<?php 
include_once "header.php";
require_once "../dao/search.php";
require_once "../dao/database.php";

echo "<div class='container'>
		<div class='row'>";

include_once "sidebar.php";
echo "<div class='span9'>";

$modul=$_GET['modul'];
$id=$_GET['id'];
$breadcrump ="";

include "../../config/paging.php";

switch($modul){

	default :

	$p = new Paging;
    $batas = 10;
    $posisi = $p->cari_posisi($batas);
		
	echo "
            <h2>Hasil Pencarian</h2>
         
            <table class='table'>
            <thead><th>No</th><th>Nama Produk</th><th>Penampakan</th><th>Jenis</th><th>Nama Toko Penjual</th><th>Harga Rp.</th><th>Beli</th></thead>";
            $no=$posisi+1;
	
	$class_db = new Database;
	$search = new Search($class_db);
	$search->search($query,$posisi,$batas);
	//print_r ($search->search($query,$posisi,$batas));
	
	$data = $search->search;
	
	if($data!=null) {
            
           foreach($data as $search) {            
            
				$price= number_format($search->price,2,',','.');
				echo "<tr>
					<td>#$no</td>
					<td><a href='product.php?id=$search->id'>$search->name</a></td>
					<td><div class=span1><div class=thumbnail><img src='../../images/produk/$search->image'></div></div></td>
					<td>$search->type</td>                
					<td><a href='store.php?id=$search->store_id'>$search->store</a></td>
					<td>$price</td>
					<td><a class='prod_cart' href=\"product_aksi.php?modul=cart&id=$search->id\">Beli</td></td>
					</tr>";
					$no++;
			}
	 
				echo "<tr><td colspan=6></td></tr></table>";
	/*}else{
            echo "<tr><td colspan=5 align=center>DATA TIDAK DITEMUKAN</td></tr>";
        }*/
	
	echo "<div class=span8>";
			$jml_data = count($data);
			$jml_halaman = $p->jml_halaman($jml_data, $batas);
			
			$link_halaman = $p->navHalaman(null, $_GET['halaman'],$jml_halaman);
            
            echo $link_halaman;
	
	echo "</div>";
	}else{
            echo "<tr><td colspan=5 align=center>DATA TIDAK DITEMUKAN</td></tr>";
        }
	break;
	}
	echo "</div>";
	echo "</div>";
	echo "</div>";

	include_once "footer.php";
?>	
